using UnityEngine;
using System;

public enum TramsformProperty
{
    Position_x,
    Position_y,
    Position_z,
    Rotate,
    Scale_x,
    Scale_y,
    Scale_z,
    Scale_xyz,
}

[Serializable]
public class TransfromAnim : EasyAnimBase
{
    public TramsformProperty property;
    public Vector3 vector3;
    public AnimationCurve curve;
}

public class TransfromAnimation : EasyAnimation<TransfromAnim>
{
    protected override void ApplyAnim(TransfromAnim anim, float process)
    {
        float val = anim.curve.Evaluate(process)*anim.multiply;

        switch (anim.property)
        {
            case TramsformProperty.Position_x:
                anim.targetObject.transform.localPosition = anim.vector3 + new Vector3(val, 0, 0);
                break;

            case TramsformProperty.Position_y:
                anim.targetObject.transform.localPosition = anim.vector3 + new Vector3(0, val, 0);
                break;

            case TramsformProperty.Position_z:
                anim.targetObject.transform.localPosition = anim.vector3 + new Vector3(0, 0, val);
                break;

            case TramsformProperty.Rotate:
                anim.targetObject.transform.localRotation = Quaternion.AngleAxis(val, anim.vector3);
                break;

            case TramsformProperty.Scale_x:
                anim.targetObject.transform.localScale = anim.vector3 + new Vector3(val, 0, 0);
                break;

            case TramsformProperty.Scale_y:
                anim.targetObject.transform.localScale = anim.vector3 + new Vector3(0, val, 0);
                break;

            case TramsformProperty.Scale_z:
                anim.targetObject.transform.localScale = anim.vector3 + new Vector3(0, 0, val);
                break;

            case TramsformProperty.Scale_xyz:
                anim.targetObject.transform.localScale = anim.vector3 + new Vector3(val, val, val);
                break;
        }
    }
}
